import express from 'express'
import cors from 'cors'

const app = express()

app.use(express.json()) //获取post请求数据
app.use(cors()) //解决跨域问题
app.get('/posts', (req, res) => {
    res.send(req.query)
})

app.post('/posts', (req, res) => {
  res.send(req.body)
})


app.listen(3000, () => {
    console.log('服务器启动成功')
})